package com.study.util;

import java.util.List;

public class PageTools<T> {
    private Integer initSize = 5;//每页展示几条数据
    private Integer currentPage =1;//默认当前页码
    private Integer countNum;//总数据条数
    private Integer countPage;//总页数
    private Integer prePage;//上一页re
    private Integer nextPage;//下一页
    private List<T> pageList;//页面中展示的数据集合

    public PageTools(Integer initSize, Integer currentPage, Integer countNum) {
        this.initSize = initSize;
        this.currentPage = currentPage;
        this.countNum = countNum;
        int num = this.countNum / this.initSize;
        this.countPage = this.countNum % this.initSize == 0 ? num : num + 1;
        this.prePage = this.currentPage <= 1 ? 1 : this.currentPage - 1;
        this.nextPage = this.currentPage >= this.countPage ? this.countPage : this.currentPage + 1;
    }

    public PageTools(Integer initSize, Integer currentPage, List<T> pageList) {
        this.initSize = initSize;
        this.currentPage = currentPage;
        this.pageList = pageList;
        int num = this.countNum / this.initSize;
        this.countPage = this.countNum % this.initSize == 0 ? num : num + 1;
        this.prePage = this.currentPage <= 1 ? 1 : this.currentPage - 1;
        this.nextPage = this.currentPage >= this.countPage ? this.countPage : this.currentPage + 1;
    }

    public PageTools(Integer initSize, Integer currentPage, Integer countNum, List<T> pageList) {
        this.initSize = initSize;
        this.currentPage = currentPage;
        this.countNum = countNum;
        this.pageList = pageList;
        int num = this.countNum / this.initSize;
        this.countPage = this.countNum % this.initSize == 0 ? num : num + 1;
        this.prePage = this.currentPage <= 1 ? 1 : this.currentPage - 1;
        this.nextPage = this.currentPage >= this.countPage ? this.countPage : this.currentPage + 1;
    }

    public Integer getInitSize() {
        return initSize;
    }

    public void setInitSize(Integer initSize) {
        this.initSize = initSize;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getCountNum() {
        return countNum;
    }

    public void setCountNum(Integer countNum) {
        this.countNum = countNum;
    }

    public Integer getCountPage() {
        return countPage;
    }

    public void setCountPage(Integer countPage) {
        this.countPage = countPage;
    }

    public Integer getPrePage() {
        return prePage;
    }

    public void setPrePage(Integer prePage) {
        this.prePage = prePage;
    }

    public Integer getNextPage() {
        return nextPage;
    }

    public void setNextPage(Integer nextPage) {
        this.nextPage = nextPage;
    }

    public List<T> getPageList() {
        return pageList;
    }

    public void setPageList(List<T> pageList) {
        this.pageList = pageList;
    }
}
